package com.cta.view.model.report;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

public class PeriodParams {

	private static final SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy");
	
	public static final String TODAY = "today";
	public static final String YESTERDAY = "yesterday";
	public static final String THIS_WEEK = "this_week";
	public static final String LAST_WEEK = "last_week";
	public static final String THIS_MONTH = "this_month";
	public static final String LAST_MONTH = "last_month";
	public static final String THIS_YEAR = "this_year";
	public static final String ALL_CALL = "all_call";
	
	
	public static final String HOURS = "hours";
	public static final String DAYS = "days";
	public static final String WEEKS = "weeks";
	public static final String MONTHS = "months";
	public static final String YEARS = "years";
	
	private String type;
	private String presetValue;
	private String lastValue;
	private int lastTime;
	private Date fromDate;
	private Date toDate;

	public PeriodParams(Map periodMap) {
		try {
			if (periodMap != null) {
				this.type = (String) periodMap.get("type");
				if ("preset".equals(type)) {
					this.presetValue = (String) periodMap.get("presetValue");
				} else if ("last".equals(type)) {
					this.lastValue = (String) periodMap.get("lastValue");
					this.lastTime = (Integer) periodMap.get("lastTime");
				} else if ("from".equals(type)) {
					String fromDate = (String) periodMap.get("fromDate");
					this.fromDate = sf.parse(fromDate);
					String toDate = (String) periodMap.get("toDate");
					this.toDate = sf.parse(toDate);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getPresetValue() {
		return presetValue;
	}

	public void setPresetValue(String presetValue) {
		this.presetValue = presetValue;
	}

	public String getLastValue() {
		return lastValue;
	}

	public void setLastValue(String lastValue) {
		this.lastValue = lastValue;
	}

	public Date getFromDate() {
		return fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public Date getToDate() {
		return toDate;
	}

	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}

	public int getLastTime() {
		return lastTime;
	}

	public void setLastTime(int lastTime) {
		this.lastTime = lastTime;
	}

}
